package vinnichenko.lab3.exception;

/**Exception for handling XML transformation errors.
 * @author Igor Vinnichenko
 * @version 1.0
 */
public class XSLTTransformingException extends Exception{
    /**UID*/
    private static final long serialVersionUID = 105L;

    /**The cause of exception*/
    private Exception detail;

    /**Constructor*/
    public XSLTTransformingException(){
    }

    /**Constructor with message*/
    public XSLTTransformingException(String msg){
        super(msg);
    } 

    /**Constructor with message and cause*/
    public XSLTTransformingException(String msg, Exception detail){
        super(msg);
        initCause(detail);
        this.detail = detail;
    } 
    
    /**Method returns a message indicating what went wrong
     * @return the chained message
     */
    public String getMessage(){
        if (detail == this || detail == null)
            return super.getMessage();
        return super.getMessage() + "; " + detail;
    }

    /**Returns the cause of this exception.
     * @return the cause
     */
    public Throwable getCause(){
        return detail == this ? null : detail;
    }
}